<div class="layuimini-container layui-anim layui-anim-upbit">
    <div class="layuimini-main">
    
        <table class="layui-hide" id="myTable" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="deal">处理</a>
        </script>

    </div>
</div>

<script th:inline="javascript">
	layui.use(['form', 'table','layuimini','element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layuimini = layui.layuimini;
            
        table.render({
            elem: '#myTable',
            url: 'getXjTaskList',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [
		            [
		                {field: 'user_id', width: 100, title: '申请人'},
		                {field: 'leave_type', width: 100, title: '类型'},
		                {field: 'start_time', width: 100, title: '请假开始时间'},
		                {field: 'end_time', width: 100, title: '请假结束时间'},
		                {field: 'reason', width: 150, title: '请假原因'},
		                {field: 'taskid', width: 80, title: '任务ID'},
		                {field: 'taskname', width: 150, title: '任务名称'},
		                {field: 'process_instance_id', width: 80, title: '流程实例ID'},
		                {field: 'taskcreatetime', width: 150, title: '任务创建时间'},
		                {title: '操作', minWidth: 80, templet: '#currentTableBar', fixed: "right", align: "center"}
		            ]
            ],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true
        });
        
        // 监听删除操作
	    table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'deal') {
            	var content = layuimini.getHrefContent('xjDeal');
                var openWH = layuimini.getOpenWidthHeight();
                var index = layer.open({
                    title: '销假',
                    type: 1,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: [openWH[0] + 'px', openWH[1] + 'px'],
                    offset: [openWH[2] + 'px', openWH[3] + 'px'],
                    content: content,
                    success:function(){
                    	layer.iframeAuto(index);
						$("#userId").val(data.user_id);
						$("#taskcreatetime").val(data.taskcreatetime);
						$("#leave_type").val(data.leave_type);
						$("#start_time").val(data.start_time);
						$("#end_time").val(data.end_time);
						$("#reason").val(data.reason);
						$("#taskId").val(data.taskid);
                    },
                    end:function(){
                    	//执行搜索重载
			            table.reload('myTable', {
			                page: {
			                    curr: 1
			                }
			            });
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        });
    });
    
</script>